string_encrypt
This function encrypts a string based on a provided key.
string string_encrypt(string the_string, string encryption_key)
Parameters:
the_string
The string to encrypt.
encryption_key
The key that will be used to encrypt and later decrypt the data.
Return value:
The encrypted string on success, or a blank string on failure.
Remarks:
This uses the AES-Rijndel 256-bit encryption algorithm, which is one of the most secure algorithms available to date. It has never been successfully cracked, and is used to protect files stored by various governments.
Strings produced by string_encrypt are not compatible with files produced by file_encrypt.
This function will encrypt both binary and text-only strings.
The encrypted string is a few bytes longer than its decrypted equivalent.
The encrypted data is in binary form. Thus, if you print out an encrypted string directly, the output will be garbled. If you need to print out an encrypted string, use the string_to_hex function to convert it into hexadecimal.
Example:
// Encrypt a string and print it.
void main()
{
string test=string_encrypt("I am an encrypted string.", "you_are_not_hacking_into_me");
test=string_to_hex(test);
alert("Encrypted string", test);
}